<%
var headerPart = {
%>
<% include("/include/treeview.html"){} %>
<style type="text/css">
	.ztree {overflow:auto;margin:0;_margin-top:5px;padding:5px 0 0 0px;}
	.ztree *{font-size: 14px!important;}
	html{
		background-color: #fff!important;
	}
</style>
<script type="text/javascript">
    $(document).ready(function(){
        var setting = {view:{selectedMulti:false},data:{simpleData:{enable:true}}};
        var zNodes=[<%for(tpl in categoryList){%>
            {id:'${tpl.id}', pId:'${isNotEmpty(tpl.parent)?tpl.parent.id:0}', name:"${tpl.name}", url:"${ctx}/cms/${isNotEmpty(tpl.module)?tpl.module:'none'}/?category.id=${tpl.id}", target:"cmsMainFrame"},
    	<%}%>];
        for(var i=0; i<zNodes.length; i++) {
            // 移除父节点
            if (zNodes[i] && zNodes[i].id == 1){
                zNodes.splice(i, 1);
            }
        }
        // 初始化树结构
        var tree = $.fn.zTree.init($("#tree"), setting, zNodes);
        // 展开第一级节点
        var nodes = tree.getNodesByParam("level", 0);
        for(var i=0; i<nodes.length; i++) {
            tree.expandNode(nodes[i], true, true, false);
        }
        // 展开第二级节点
        nodes = tree.getNodesByParam("level", 1);
        for(var i=0; i<nodes.length; i++) {
            tree.expandNode(nodes[i], true, true, false);
        }
        wSize();
    });
    $(window).resize(function(){
        wSize();
    });
    function wSize(){
        $(".ztree").width($(window).width()-16).height($(window).height()-62);
        $(".ztree").css({"overflow":"auto","overflow-x":"auto","overflow-y":"auto"});
        $("html,body").css({"overflow":"hidden","overflow-x":"hidden","overflow-y":"hidden"});
    }
</script>
<% }; %>
<% layout("/layouts/micro.html",{headerSection:headerPart}){ %>
	<div id="tree" class="ztree"></div>
<%}%>